package InterfaceLambdaAndInnerClasses.staticInnerClass;

class ArrayAlg {
    static class Pair{
        private double first;
        private double second;

        Pair(double first, double second) {
            this.first = first;
            this.second = second;
        }

        double getFirst() {
            return first;
        }

        double getSecond() {
            return second;
        }
    }

    /**
     * Computes both the minimum and the maximum of an array
     * @param value an array of floating-point numbers
     * @return a pair whose first element is the minimum and whose second element
     */
    static Pair minmax(double[] value){
        double min=Double.POSITIVE_INFINITY;
        double max=Double.NEGATIVE_INFINITY;

        for (double v:value){
            if(min>v) min=v;
            if (max<v) max=v;
        }
        return new Pair(min,max);
    }
}
